OSDN Git Service

[SOUND][Qt] Fix stopping sound after using debugger.
authorK.Ohta <whatisthis.sowhat@gmail.com>
Tue, 10 Jan 2023 05:08:58 +0000 (14:08 +0900)
committerK.Ohta <whatisthis.sowhat@gmail.com>
Tue, 10 Jan 2023 05:08:58 +0000 (14:08 +0900)
18 files changed:
source/src/debugger.cpp
source/src/emu.cpp
source/src/emu.h
source/src/emu_template.h
source/src/qt/CMakeLists.txt
source/src/qt/avio/CMakeLists.txt
source/src/qt/emuutils/CMakeLists.txt
source/src/qt/gui/CMakeLists.txt
source/src/qt/gui/qt_debugger_tmpl.cpp
source/src/qt/osd_base.cpp
source/src/qt/osd_base.h
source/src/qt/osd_sound.cpp
source/src/qt/sound-drivers/common/osd_sound_mod_template.cpp
source/src/qt/sound-drivers/osd_sound_mod_template.h
source/src/qt/sound-drivers/qt_multimedia/osd_sound_mod_qtmultimedia.cpp
source/src/qt/sound-drivers/qt_multimedia/osd_sound_mod_qtmultimedia.h
source/src/vm/common_vm/CMakeLists.txt
source/src/vm/fmgen/CMakeLists.txt

index 94664a3..fbc8e93 100644 (file)
@@ -1938,13 +1938,15 @@ void EMU::initialize_debugger()
 
 void EMU::release_debugger()
 {
-       close_debugger();
+       for(int i = 0; i < 8; i++) { // ToDo 20230110 K.O
+               close_debugger(i);
+       }
 }
 
 void EMU::open_debugger(int cpu_index)
 {
        if(!(now_debugging && debugger_thread_param.cpu_index == cpu_index)) {
-               close_debugger();
+               close_debugger(cpu_index);
                if(vm->get_cpu(cpu_index) != NULL && vm->get_cpu(cpu_index)->get_debugger() != NULL) {
                        debugger_thread_param.emu = this;
                        debugger_thread_param.osd = (OSD_BASE*)osd;
@@ -1967,8 +1969,9 @@ void EMU::open_debugger(int cpu_index)
        }
 }
 
-void EMU::close_debugger()
+void EMU::close_debugger(int cpu_index)
 {
+       
        if(now_debugging) {
                if(debugger_thread_param.running) {
                        debugger_thread_param.request_terminate = true;
@@ -1979,17 +1982,19 @@ void EMU::close_debugger()
 //#elif !defined(_USE_QT)
 #else
                pthread_join(debugger_thread_id, NULL);
-//#else
-//             volatile debugger_thread_t *p = (debugger_thread_t *)(&debugger_thread_param);
-//             p->running = false;
-               
-               //if(logfile != NULL && logfile->IsOpened()) {
-               //      logfile->Fclose();
-               //}
-               // initialize logfile
-               //logfile = NULL;
 #endif
                now_debugging = false;
+               DEVICE *cpu = vm->get_cpu(cpu_index);
+               DEBUGGER *cpu_debugger = nullptr;
+               if(cpu != nullptr) {
+                       cpu_debugger = (DEBUGGER*)cpu->get_debugger();
+               }
+               if((cpu != nullptr) && (cpu_debugger != nullptr)) {
+                       cpu_debugger->now_debugging = false;
+                       cpu_debugger->now_going = true;
+                       // ToDo: Support multiple CPUs
+                       debugger_thread_param.cpu_index = -1;
+               }
        }
 }
 // Some functions move to emu.cpp . 20190221 K.O.
index 56094e7..957d59c 100644 (file)
@@ -225,6 +225,7 @@ int EMU::run()
                        load_state(state_file_path(request_load_state));
                }
                // NOTE: vm instance may be reinitialized in load_state
+               // ToDo: Support multiple debuggers. 20230110 K.O
                if(!is_debugger_enabled(debugger_cpu_index)) {
                        for(int i = 0; i < 8; i++) {
                                if(is_debugger_enabled(i)) {
@@ -243,7 +244,7 @@ int EMU::run()
                        cpu_debugger->now_debugging = true;
                        debugger_thread_param.vm = vm;
                } else {
-                       close_debugger();
+                       close_debugger(debugger_cpu_index);
                }
                request_save_state = request_load_state = -1;
        }
@@ -2047,6 +2048,7 @@ void EMU::finish_waiting_in_debugger()
 #ifdef USE_DEBUGGER
        osd->finish_waiting_in_debugger();
        now_waiting_in_debugger = false;
+       osd->unmute_sound();
 #endif
 }
 
index 8be468e..7338b9a 100644 (file)
@@ -288,7 +288,7 @@ public:
        // debugger
 #ifdef USE_DEBUGGER
        void open_debugger(int cpu_index) override;
-       void close_debugger() override;
+       void close_debugger(int cpu_index) override;
        bool is_debugger_enabled(int cpu_index) override;
 #endif
        void start_waiting_in_debugger() override;
index 23013f2..b213f4d 100644 (file)
@@ -369,7 +369,7 @@ public:
        virtual void release_debugger() { }
        
        virtual void open_debugger(int cpu_index) {}
-       virtual void close_debugger() {}
+       virtual void close_debugger(int cpu_index) {}
        virtual bool is_debugger_enabled(int cpu_index) { return false; }
        
        bool now_debugging;
index 20dae1a..b9aae93 100644 (file)
@@ -1,5 +1,5 @@
 message("* qt/osd")
-SET(THIS_LIB_VERSION 8.9.1)
+SET(THIS_LIB_VERSION 8.10.0)
 
 set(s_qt_osd_headers
        osd_base.h
index d584bcd..226e601 100644 (file)
@@ -1,6 +1,6 @@
 message("* qt/avio")
 
-SET(THIS_LIB_VERSION 7.4.1)
+SET(THIS_LIB_VERSION 7.4.2)
 set(s_qt_avio_headers
        csp_avio_basic.h
        movie_saver.h
index 7373f22..69d08d5 100644 (file)
@@ -1,6 +1,6 @@
 message("* qt/emuutils")
 
-SET(THIS_LIB_VERSION 7.5.0)
+SET(THIS_LIB_VERSION 7.5.1)
 
 set(s_qt_emuutils_headers
        ../gui/csp_logger.h
index 773b2bd..9047172 100644 (file)
@@ -1,6 +1,6 @@
 message("* qt/gui")
 
-set(THIS_LIB_VERSION 7.4.1)
+set(THIS_LIB_VERSION 7.5.0)
 
 set(s_qt_gui_headers
          qt_dialogs.h
index 20e98f6..ae6c7cf 100644 (file)
@@ -183,9 +183,10 @@ void CSP_Debugger_Tmpl::closeEvent(QCloseEvent *event)
        if(emu != nullptr) {
                VM_TEMPLATE* p_vm = debugger_thread_param.vm;
                if(p_vm != nullptr) {
+                       // ToDo: Support multiple debuggers. 20230110 K.O
                        uint32_t cpu_index = debugger_thread_param.cpu_index;
                        if(emu->is_debugger_enabled(cpu_index)) {
-                               emu->close_debugger();
+                               emu->close_debugger(cpu_index);
                        }
                }
        }
@@ -291,7 +292,7 @@ CSP_Debugger_Tmpl::~CSP_Debugger_Tmpl()
        if(emu != nullptr) {
                uint32_t cpu_index = debugger_thread_param.cpu_index;
                if(emu->is_debugger_enabled(cpu_index)) {
-                       emu->close_debugger();
+                       emu->close_debugger(cpu_index);
                }
        }
        //emu.reset(); // Deallocate
index ff32b01..1b003df 100644 (file)
@@ -147,6 +147,7 @@ void OSD_BASE::restore()
                        play_movie();
                }
        }
+       unmute_sound();
 }
 
 
index bef12f9..7ce1141 100644 (file)
@@ -549,6 +549,7 @@ public:
        // common sound
        void update_sound(int* extra_frames);
        void mute_sound();
+       void unmute_sound();
        void stop_sound();
        void start_record_sound();
        void stop_record_sound();
index 9a0bf27..b6951d5 100644 (file)
@@ -621,6 +621,17 @@ void OSD_BASE::init_sound_device_list()
                }
        }
 }
+
+void OSD_BASE::unmute_sound()
+{
+       if(now_mute && sound_ok) {
+               std::shared_ptr<SOUND_MODULE::OUTPUT::M_BASE>sound_drv = m_sound_driver;
+               if(sound_drv.get() != nullptr) {
+                       sound_drv->unmute_sound();
+               }
+               now_mute = false;
+       }
+}
 void OSD_BASE::mute_sound()
 {
        if(!now_mute && sound_ok) {
index 0337e3f..27a4e73 100644 (file)
@@ -216,6 +216,7 @@ public slots:
        virtual void initialize_sound(int rate, int samples, int* presented_rate, int* presented_samples);
        virtual void release_sound();
        virtual void mute_sound();
+       virtual void unmute_sound();
        virtual void stop_sound();
        
        virtual void update_config() {}
index 446b88d..1203deb 100644 (file)
@@ -706,12 +706,11 @@ bool M_QT_MULTIMEDIA::is_driver_started()
 void M_QT_MULTIMEDIA::mute_sound()
 {
        if(!(m_mute.load()) && (m_config_ok.load())) {
-               #if QT_VERSION >= QT_VERSION_CHECK(6, 2, 0)
+       #if QT_VERSION >= QT_VERSION_CHECK(6, 2, 0)
                std::shared_ptr<QAudioSink> p = m_audioOutputSink;
-               #elif QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
+       #elif QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
                std::shared_ptr<QAudioOutput> p = m_audioOutputSink;
-               #endif
-               
+       #endif
                if(p.get() != nullptr) {
                        switch(p->state()) {
                        case QAudio::ActiveState:
@@ -727,6 +726,29 @@ void M_QT_MULTIMEDIA::mute_sound()
        m_mute = true;
 }
 
+void M_QT_MULTIMEDIA::unmute_sound()
+{
+       if((m_mute.load()) && (m_config_ok.load())) {
+       #if QT_VERSION >= QT_VERSION_CHECK(6, 2, 0)
+               std::shared_ptr<QAudioSink> p = m_audioOutputSink;
+       #elif QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
+               std::shared_ptr<QAudioOutput> p = m_audioOutputSink;
+       #endif
+               if(p.get() != nullptr) {
+                       switch(p->state()) {
+                       case QAudio::SuspendedState:
+                               emit sig_discard_audio();
+                               emit sig_resume_audio();
+                               break;
+                       default:
+                               break;
+                       }
+               }
+       }
+       m_mute = false; 
+}
+
+
 void M_QT_MULTIMEDIA::do_discard_sound()
 {
        std::shared_ptr<SOUND_BUFFER_QT> q = m_driver_fileio;
index dd75410..3295437 100644 (file)
@@ -92,6 +92,7 @@ public slots:
        virtual void release_sound() override;
 
        virtual void mute_sound() override;
+       virtual void unmute_sound() override;
        virtual void stop_sound() override;
        
        virtual void driver_state_changed(QAudio::State newState);
index baffded..8383c4d 100644 (file)
@@ -1,6 +1,6 @@
 message("* vm/common_vm")
 
-SET(THIS_LIB_VERSION 7.1.0)
+SET(THIS_LIB_VERSION 7.2.0)
 
 #include(cotire)
 set(s_vm_common_vm_srcs
index 8b2d6b4..9a58c09 100644 (file)
@@ -1,7 +1,7 @@
 cmake_minimum_required (VERSION 3.0)
 
 message("* vm/fmgen")
-SET(THIS_LIB_VERSION 5.4.1)
+SET(THIS_LIB_VERSION 5.4.2)
 add_definitions(-D__LIBFMGEN_VERSION=\"libCSPfmgen.${THIS_LIB_VERSION}\")
 
 SET(s_vm_fmgen_srcs