From 7edefc726642d4ae477307f06ce65456e3d66d62 Mon Sep 17 00:00:00 2001 From: "K.Ohta" Date: Fri, 27 May 2016 19:35:10 +0900 Subject: [PATCH] [Qt][OSD] Prepair to add recording to video. --- source/src/qt/CMakeLists.txt | 4 ++-- source/src/qt/osd.h | 2 +- source/src/qt/osd_base.h | 6 +++++- source/src/qt/osd_screen.cpp | 41 ++++++++++++----------------------------- source/src/qt/osd_sound.cpp | 14 ++++++++++++++ 5 files changed, 34 insertions(+), 33 deletions(-) diff --git a/source/src/qt/CMakeLists.txt b/source/src/qt/CMakeLists.txt index ab22856cc..eff2706f7 100644 --- a/source/src/qt/CMakeLists.txt +++ b/source/src/qt/CMakeLists.txt @@ -39,8 +39,8 @@ else() ) set_target_properties(CSPosd PROPERTIES - SOVERSION 1.1.0 - VERSION 1.1.0 + SOVERSION 1.1.1 + VERSION 1.1.1 ) INSTALL(TARGETS CSPosd DESTINATION ${LIBCSP_INSTALL_DIR}) endif() diff --git a/source/src/qt/osd.h b/source/src/qt/osd.h index 3ecdd88d9..83b28ab06 100644 --- a/source/src/qt/osd.h +++ b/source/src/qt/osd.h @@ -51,7 +51,6 @@ protected: void vm_key_up(int code); void vm_reset(void); void update_buttons(bool press_flag, bool release_flag); - QString get_vm_config_name(void); int get_screen_width(void); int get_screen_height(void); int get_vm_buttons_code(int num); @@ -72,6 +71,7 @@ public: void release_screen(); int get_window_mode_width(int mode); int get_window_mode_height(int mode); + QString get_vm_config_name(void); }; QT_END_NAMESPACE diff --git a/source/src/qt/osd_base.h b/source/src/qt/osd_base.h index 5f84234bc..55e8bf230 100644 --- a/source/src/qt/osd_base.h +++ b/source/src/qt/osd_base.h @@ -18,6 +18,7 @@ #include #include #include +#include #include #include "simd_types.h" @@ -255,7 +256,6 @@ protected: virtual void vm_key_up(int code); virtual void vm_reset(void); virtual void update_buttons(bool press_flag, bool release_flag); - virtual QString get_vm_config_name(void); virtual int get_screen_width(void); virtual int get_screen_height(void); virtual int get_vm_buttons_code(int num); @@ -356,6 +356,7 @@ public: void stop_record_sound(); void restart_record_sound(); bool now_record_sound; + int get_sound_rate(); // common video device void get_video_buffer(); @@ -427,6 +428,7 @@ public: virtual void force_unlock_vm(void); virtual bool is_vm_locked(void); virtual void set_draw_thread(DrawThreadClass *handler); + virtual QString get_vm_config_name(void); public slots: void do_write_inputdata(QString s); @@ -442,6 +444,8 @@ signals: int sig_resize_vm_screen(QImage *, int, int); int sig_put_string_debugger(QString); int sig_console_input_string(QString); + int sig_enqueue_video(QByteArray *data, int width, int height); + int sig_enqueue_audio(QByteArray *data); int sig_debugger_finished(); }; QT_END_NAMESPACE diff --git a/source/src/qt/osd_screen.cpp b/source/src/qt/osd_screen.cpp index 749a39719..2c3b13ef8 100644 --- a/source/src/qt/osd_screen.cpp +++ b/source/src/qt/osd_screen.cpp @@ -308,10 +308,9 @@ int OSD_BASE::add_video_frames() static int prev_video_fps = -1; int counter = 0; static double prev_vm_fps = -1; -#if 0 + if(get_support_variable_timing()) { double vm_fps = vm_frame_rate(); - prev_vm_fps = -1; if(prev_video_fps != rec_video_fps || prev_vm_fps != vm_fps) { prev_video_fps = rec_video_fps; @@ -321,7 +320,7 @@ int OSD_BASE::add_video_frames() } else { if(prev_video_fps != rec_video_fps) { prev_video_fps = rec_video_fps; - frames = FRAMES_PER_SEC / rec_video_fps; + frames = vm_frame_rate() / rec_video_fps; } } while(rec_video_run_frames > 0) { @@ -330,33 +329,17 @@ int OSD_BASE::add_video_frames() counter++; } if(counter != 0) { - if(hVideoThread != (HANDLE)0) { - if(rec_video_thread_param.result == 0) { - WaitForSingleObject(hVideoThread, INFINITE); - } - hVideoThread = (HANDLE)0; - - if(rec_video_thread_param.result == REC_VIDEO_FULL) { - stop_record_video(); - if(!start_record_video(-1)) { - return 0; - } - } else if(rec_video_thread_param.result == REC_VIDEO_ERROR) { - stop_record_video(); - return 0; - } - } -// BitBlt(vm_screen_buffer.hdcDib, 0, 0, vm_screen_buffer.width, vm_screen_buffer.height, video_screen_buffer.hdcDib, 0, 0, SRCCOPY); - memcpy(video_screen_buffer.lpBmp, vm_screen_buffer.lpBmp, sizeof(scrntype_t) * vm_screen_buffer.width * vm_screen_buffer.height); - - rec_video_thread_param.frames += counter; - rec_video_thread_param.result = 0; - if((hVideoThread = (HANDLE)_beginthreadex(NULL, 0, rec_video_thread, &rec_video_thread_param, 0, NULL)) == (HANDLE)0) { - stop_record_video(); - return 0; - } + // int size = vm_screen_buffer.width, vm_screen_buffer.height; + // Rescaling + //QByteArray video_result(size, vm_screen_buffer.pImage.constData()); + //while(counter > 0) { + // Enqueue to frame. + //if(movie_saver != NULL) { + // emit sig_enqueue_video(&video_result, vm_screen_buffer.width, vm_screen_buffer.height); + //} + //counter--; + //} } -#endif return counter; } diff --git a/source/src/qt/osd_sound.cpp b/source/src/qt/osd_sound.cpp index 60e45a34c..3e3016ee6 100644 --- a/source/src/qt/osd_sound.cpp +++ b/source/src/qt/osd_sound.cpp @@ -204,6 +204,14 @@ void OSD_BASE::update_sound(int* extra_frames) //SDL_UnlockAudio(); // sound buffer must be updated Sint16* sound_buffer = (Sint16 *)this->create_sound(extra_frames); + if(now_record_video) { + if(sound_samples > rec_sound_buffer_ptr) { + int samples = sound_samples - rec_sound_buffer_ptr; + int length = samples * sizeof(int16_t) * 2; // stereo + //QByteArray *p = new QByteArray((const char *)sound_buffer + rec_sound_buffer_ptr * 2, length); + //emit sig_enqueue_audio(p); + } + } if(now_record_sound) { // record sound if(sound_samples > rec_sound_buffer_ptr) { @@ -211,6 +219,7 @@ void OSD_BASE::update_sound(int* extra_frames) int length = samples * sizeof(int16_t) * 2; // stereo rec_sound_fio->Fwrite(sound_buffer + rec_sound_buffer_ptr * 2, length, 1); rec_sound_bytes += length; +#if 0 if(now_record_video) { // sync video recording static double frames = 0; @@ -237,6 +246,7 @@ void OSD_BASE::update_sound(int* extra_frames) } // rec_video_run_frames -= rec_video_frames; } +#endif // printf("Wrote %d samples\n", samples); rec_sound_buffer_ptr += samples; if(rec_sound_buffer_ptr >= sound_samples) rec_sound_buffer_ptr = 0; @@ -419,3 +429,7 @@ void OSD_BASE::restart_record_sound() } } +int OSD_BASE::get_sound_rate() +{ + return sound_rate; +} -- 2.11.0