@@ -433,7 +433,7 @@ void USBSID_Class::USBSID_ToggleStereo(void)
433433
434434/* SYNCHRONOUS */
435435
436- void USBSID_Class::USBSID_SingleWrite (unsigned char *buff, size_t len)
436+ void USBSID_Class::USBSID_SingleWrite (unsigned char *buff, int len)
437437{
438438 if (!us_Initialised) return ;
439439 int actual_length = 0 ;
@@ -462,7 +462,7 @@ unsigned char USBSID_Class::USBSID_SingleRead(uint8_t reg)
462462 return result[0 ];
463463}
464464
465- unsigned char USBSID_Class::USBSID_SingleReadConfig (unsigned char *buff, size_t len)
465+ unsigned char USBSID_Class::USBSID_SingleReadConfig (unsigned char *buff, int len)
466466{
467467 if (!us_Initialised) return 0 ;
468468 int actual_length;
@@ -550,8 +550,8 @@ void USBSID_Class::USBSID_WriteCycled(uint8_t reg, uint8_t val, uint16_t cycles)
550550 write_buffer[0 ] = (CYCLED_WRITE << 6 );
551551 write_buffer[1 ] = (reg & 0xFF );
552552 write_buffer[2 ] = val;
553- write_buffer[3 ] = (cycles >> 8 );
554- write_buffer[4 ] = (cycles & 0xFF );
553+ write_buffer[3 ] = (uint8_t )( cycles >> 8 );
554+ write_buffer[4 ] = (uint8_t )( cycles & 0xFF );
555555 USBSID_Write (write_buffer, 5 );
556556 return ;
557557}
@@ -655,8 +655,8 @@ int USBSID_Class::USBSID_InitThread(void)
655655 flush_buffer = 0 ;
656656 run_thread = buffer_pos = 1 ;
657657 threaded = withcycles = true ;
658- pthread_mutex_lock (&us_mutex);
659658 USBSID_InitRingBuffer (ring_size, diff_size);
659+ pthread_mutex_lock (&us_mutex);
660660 us_thread++;
661661 pthread_mutex_unlock (&us_mutex);
662662 int error;
@@ -843,8 +843,8 @@ void USBSID_Class::USBSID_FlushBuffer(void)
843843 ? (buffer_pos >= 5 )
844844 : (buffer_pos >= 3 ))) {
845845 thread_buffer[0 ] = (withcycles == 1 )
846- ? (CYCLED_WRITE << 6 | (buffer_pos - 1 ))
847- : (WRITE << 6 | (buffer_pos - 1 ));
846+ ? (uint8_t )( CYCLED_WRITE << 6 | (buffer_pos - 1 ))
847+ : (uint8_t )( WRITE << 6 | (buffer_pos - 1 ));
848848 memcpy (out_buffer, thread_buffer, buffer_pos);
849849 buffer_pos = 1 ;
850850 flush_buffer = 0 ;
@@ -876,8 +876,8 @@ void USBSID_Class::USBSID_WriteRingCycled(uint8_t reg, uint8_t val, uint16_t cyc
876876 if (threaded && withcycles) {
877877 USBSID_RingPut (reg);
878878 USBSID_RingPut (val);
879- USBSID_RingPut ((cycles >> 8 ) & 0xFF );
880- USBSID_RingPut (cycles & 0xFF );
879+ USBSID_RingPut ((uint8_t )( cycles >> 8 ) & 0xFF );
880+ USBSID_RingPut (( uint8_t )( cycles & 0xFF ) );
881881 } else {
882882 USBERR (stderr, " [USBSID] Function '%s' cannot be used when threaded = %d and withcycles = %d\n " , __func__, threaded, withcycles);
883883 }
@@ -895,7 +895,7 @@ void USBSID_Class::USBSID_RingPopCycled(void)
895895 || buffer_pos == len_out_buffer
896896 || flush_buffer == 1 ) {
897897 flush_buffer = 0 ;
898- thread_buffer[0 ] = (CYCLED_WRITE << 6 | (buffer_pos - 1 ));
898+ thread_buffer[0 ] = (uint8_t )(( CYCLED_WRITE << 6 ) | (buffer_pos - 1 ));
899899 memcpy (out_buffer, thread_buffer, buffer_pos);
900900 buffer_pos = 1 ;
901901 libusb_submit_transfer (transfer_out);
@@ -917,7 +917,7 @@ void USBSID_Class::USBSID_RingPop(void)
917917 || buffer_pos == len_out_buffer
918918 || flush_buffer == 1 ) {
919919 flush_buffer = 0 ;
920- thread_buffer[0 ] = (WRITE << 6 | (buffer_pos - 1 ));
920+ thread_buffer[0 ] = (uint8_t )(( WRITE << 6 ) | (buffer_pos - 1 ));
921921 memcpy (out_buffer, thread_buffer, buffer_pos);
922922 buffer_pos = 1 ;
923923 libusb_submit_transfer (transfer_out);
@@ -951,14 +951,14 @@ uint8_t USBSID_Class::USBSID_Address(uint16_t addr)
951951 static uint8_t a;
952952 switch (addr) {
953953 case 0xD400 ... 0xD499 :
954- a = (addr & SIDLMASK); /* $D400 -> $D479 1, 2, 3 & 4 */
954+ a = (uint8_t )( addr & SIDLMASK); /* $D400 -> $D479 1, 2, 3 & 4 */
955955 break ;
956956 case 0xD500 ... 0xD599 :
957957 case 0xDE00 ... 0xDF99 :
958958 a = ((SID3ADDR | (addr & SID2MASK)) & SIDLMASK);
959959 break ;
960960 default :
961- a = (addr & SIDLMASK);
961+ a = (uint8_t )( addr & SIDLMASK);
962962 break ;
963963 }
964964 return a;
@@ -973,15 +973,15 @@ uint_fast64_t USBSID_Class::USBSID_CycleFromTimestamp(timestamp_t timestamp)
973973 USBSID_GetClockRate (); /* Make sure we use the right clockrate */
974974 us_InvCPUcycleDurationNanoSeconds = 1.0 / (ratio_t ::den / (float )cycles_per_sec);
975975 auto nsec = std::chrono::duration_cast<std::chrono::nanoseconds>(timestamp - m_StartTime);
976- return (int_fast64_t )(nsec.count () * us_InvCPUcycleDurationNanoSeconds);
976+ return (int_fast64_t )(( double ) nsec.count () * us_InvCPUcycleDurationNanoSeconds);
977977}
978978
979979uint_fast64_t USBSID_Class::USBSID_WaitForCycle (uint_fast16_t cycles)
980980{ /* Returns the waited microseconds since last target time ~ not the actual cycles */
981981 if (!us_Initialised) return 0 ;
982982 USBSID_GetClockRate (); /* Make sure we use the right clockrate */
983983 timestamp_t now = std::chrono::high_resolution_clock::now ();
984- double dur = cycles * us_CPUcycleDuration; /* duration in nanoseconds */
984+ double dur = ( double ) cycles * us_CPUcycleDuration; /* duration in nanoseconds */
985985 duration_t duration = (duration_t )(int_fast64_t )dur; /* equals dur but as chrono nanoseconds */
986986 auto target_time = m_LastTime + duration; /* ns to wait since m_LastTime (now + duration for actual wait time) */
987987 // auto target_time = now + duration; /* ns to wait since m_LastTime (now + duration for actual wait time) */
@@ -993,7 +993,7 @@ uint_fast64_t USBSID_Class::USBSID_WaitForCycle(uint_fast16_t cycles)
993993 }
994994 m_LastTime = target_time;
995995 /* int_fast64_t waited_cycles = wait_usec.count(); */
996- int_fast64_t waited_cycles = (wait_nsec.count () * us_InvCPUcycleDurationNanoSeconds);
996+ int_fast64_t waited_cycles = (int_fast64_t )(( double ) wait_nsec.count () * us_InvCPUcycleDurationNanoSeconds);
997997 // USBDBG(stdout, "[C] %ld [WC] %ld [us] %ld [ns] %ld [ts] %lu\n",
998998 // cycles, waited_cycles, wait_usec.count(), wait_nsec.count(), USBSID_CycleFromTimestamp(now));
999999 // return (wait_nsec.count() > 0) ? waited_cycles : 0;
@@ -1031,7 +1031,7 @@ void USBSID_Class::LIBUSB_CloseDevice(void)
10311031 return ;
10321032}
10331033
1034- int USBSID_Class::LIBUSB_Available (libusb_context *ctx, uint16_t vendor_id, uint16_t product_id)
1034+ int USBSID_Class::LIBUSB_Available (uint16_t vendor_id, uint16_t product_id)
10351035{
10361036 struct libusb_device **devs;
10371037 struct libusb_device *dev;
@@ -1239,7 +1239,7 @@ int USBSID_Class::LIBUSB_Setup(bool start_threaded, bool with_cycles)
12391239 libusb_set_option (ctx, LIBUSB_OPTION_LOG_LEVEL, 0 );
12401240
12411241 /* Check for an available USBSID-Pico */
1242- if (LIBUSB_Available (ctx, VENDOR_ID, PRODUCT_ID) <= 0 ) {
1242+ if (LIBUSB_Available (VENDOR_ID, PRODUCT_ID) <= 0 ) {
12431243 USBDBG (stderr, " [USBSID] USBSID-Pico not connected\n " );
12441244 goto out;
12451245 }
0 commit comments